form.on('submit(sub)',function (){
    var newpwd =  $('#newpwd').val();
    var confirmpwd = $('#confirmpwd').val();
    if(newpwd != confirmpwd){
        $('#rcp').attr('hidden','hidden');
        $('#ecp').removeAttr('hidden');
        layer.msg("两次输入密码不一致");
        return false;
    }else{
        var data = {
            originPwd:$('#originpwd').val(),
            newPwd:$('#newpwd').val()
        }
        $.ajax({
            url:'/user/changePwd',
            type:'post',
            dataType:'text',
            contentType: 'application/json',
            data:JSON.stringify(data),
            timeout:2000,
            beforeSend:function (xhr) {
                xhr.setRequestHeader(header,token);
            },
            success:function(data){
                console.log(data);
                if(data == 'success'){
                    layer.msg("密码修改成功");
                    location.href = "/user/loginpage"
                }else{
                    layer.msg("密码修改失败")
                }
            },
            error:function () {
                layer.msg("密码修改失败")
            }
        })
    }
    return false;
})